package mumu.android;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import mumu.android.view.dialog1;
import mumu.android.view.gridviewpager;
import mumu.android.view.loading1;
import mumu.android.view.loading2;
import mumu.android.view.popupwindow1;
import mumu.android.view.scroll_view;
import mumu.android.view.scroll_view_back;
import mumu.android.view.star1;
import mumu.android.view.treeview1;
import mumu.android.view.view_customer;
import mumu.android.view.view_linearlayout;
import mumu.android.view.view_relativelayout;
import mumu.android.view.webview1;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ListView;
import android.widget.SimpleAdapter;

public class ViewActivity extends ListActivity {

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setListAdapter(new SimpleAdapter(this, getData(), android.R.layout.simple_list_item_1, new String[] { "title" }, new int[] { android.R.id.text1 }));
		getListView().setTextFilterEnabled(true);
	}

	protected List getData() {
		List<Map> myData = new ArrayList<Map>();
		addItem(myData, "loading", new Intent(this, loading1.class));
		addItem(myData, "progress_bar", new Intent(this, loading2.class));
		addItem(myData, "star", new Intent(this, star1.class));
		addItem(myData, "popupwindow", new Intent(this, popupwindow1.class));
		addItem(myData, "dialog", new Intent(this, dialog1.class));
		addItem(myData, "webview", new Intent(this, webview1.class));
		addItem(myData, "gridviewpager", new Intent(this, gridviewpager.class));
		addItem(myData, "treeview1", new Intent(this, treeview1.class));
		addItem(myData, "view_linearlayout", new Intent(this, view_linearlayout.class));
		addItem(myData, "view_relativelayout", new Intent(this, view_relativelayout.class));
		addItem(myData, "view_customer", new Intent(this, view_customer.class));
		addItem(myData, "scroll_view", new Intent(this, scroll_view.class));
		addItem(myData, "scroll_view_back", new Intent(this, scroll_view_back.class));
		return myData;
	}


	protected void addItem(List<Map> data, String name, Intent intent) {
		Map<String, Object> temp = new HashMap<String, Object>();
		temp.put("title", name);
		temp.put("intent", intent);
		data.add(temp);
	}

	@Override
	protected void onListItemClick(ListView l, View v, int position, long id) {
		Map map = (Map) l.getItemAtPosition(position);
		Intent intent = (Intent) map.get("intent");
		startActivity(intent);
	}
}
